home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / mach / sun4c.md / uword.c < prev   
C/C++ Source or Header  |  1989-08-17  |  2KB  |  101 lines

  1. #ifdef sccsid
  2. static char    sccsid[] = "@(#)uword.c 1.6 88/03/30 Copyr 1987 Sun Micro";
  3. #endif
  4.  
  5. /*
  6.  * Copyright (c) 1987 by Sun Microsystems, Inc.
  7.  */
  8.  
  9. /* Read/write user memory procedures for Sparc FPU simulator. */
  10.  
  11. /*
  12.  * This whole file refuses to lint.
  13.  */
  14. #ifndef lint
  15. #include <sun4/fpu/fpu_simulator.h>
  16. #include <sun4/fpu/globals.h>
  17. #include <sys/types.h>
  18.  
  19. extern int fuword();
  20. extern int suword();
  21. extern int fubyte();
  22.  
  23. enum ftt_type
  24. _fp_read_word(address, pvalue)
  25.     caddr_t        address;
  26.     int        *pvalue;
  27. {
  28.     int        w;
  29.     int        b;
  30.  
  31.     if (((int) address & 0x3) != 0)
  32.         return (ftt_alignment);    /* Must be word-aligned. */
  33.     w = fuword(address);
  34.     if (w == -1) {
  35.         b = fubyte(address);
  36.         if (b == -1) {
  37.             fptrapaddr = address;
  38.             fptraprw = S_READ;
  39.             return (ftt_fault);
  40.         }
  41.     }
  42.     *pvalue = w;
  43.     return (ftt_none);
  44. }
  45.  
  46. enum ftt_type
  47. _fp_write_word(address, value)
  48.     caddr_t        address;
  49.     int        value;
  50. {
  51.     int        w;
  52.  
  53.     if (((int) address & 0x3) != 0)
  54.         return (ftt_alignment);    /* Must be word-aligned. */
  55.     w = suword(address, value);
  56.     if (w == -1) {
  57.         fptrapaddr = address;
  58.         fptraprw = S_WRITE;
  59.         return (ftt_fault);
  60.     } else {
  61.         return (ftt_none);
  62.     }
  63. }
  64.  
  65. enum ftt_type
  66. read_iureg(n, pregs, pwindow, pvalue)
  67.     unsigned    n;
  68.     struct regs    *pregs;    /* Pointer to PCB image of registers. */
  69.     struct rwindow    *pwindow;/* Pointer to locals and ins. */
  70.     int        *pvalue;
  71. {                /* Reads integer unit's register n. */
  72.     register int    *pint;
  73.  
  74.     if (n <= 15) {
  75.         if (n == 0) {
  76.             *pvalue = 0;
  77.             return (ftt_none);    /* Read global register 0. */
  78.         }
  79.         if (n <= 7) {    /* globals */
  80.             pint = &(pregs->r_g1) + (n - 1);
  81.             *pvalue = *pint;
  82.             return (ftt_none);
  83.         } else {    /* outs */
  84.             pint = &(pregs->r_o0) + (n - 8);
  85.             *pvalue = *pint;
  86.             return (ftt_none);
  87.         }
  88.     } else {        /* locals and ins */
  89.         if (n <= 23)
  90.             pint = &pwindow->rw_local[n - 16];
  91.         else
  92.             pint = &pwindow->rw_in[n - 24];
  93.         if ((int) pint > KERNELBASE){
  94.             *pvalue =  *pint;
  95.             return (ftt_none);
  96.         }
  97.         return _fp_read_word((char *) pint, pvalue);
  98.     }
  99. }
  100. #endif /* lint */
  101.